package com.exam.schedule;

import com.google.gson.Gson;
import com.exam.common.Utils.DateUtil;
import com.exam.controller.websocket.server.UserInfoModel;
import com.exam.controller.websocket.server.WebsocketServer;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;


@Component
public class WebsocketTask {

    @Scheduled(cron = "0 */1 * * * ?")
    public void index() {
        UserInfoModel userInfoModel = new UserInfoModel("官方提醒您", "admin", " 请文明聊天,本界面仅用于咨询，认准小程管理员，小心诈骗，请自行承担法律责任，谢谢您的合作！", DateUtil.getCurrentTimeMillis(), "https://chengke-exam.oss-cn-zhangjiakou.aliyuncs.com/2023-02-17/fa5d04ac-5d38-4baf-8c25-e2a703dc5a4b_1664250437133.jpeg");
        String msgJson = new Gson().toJson(userInfoModel);
        WebsocketServer.pushMessage("admin",msgJson , null);
    }
}
